<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Class: Ankoder::Auth</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Class</strong></td>
          <td class="class-name-in-header">Ankoder::Auth</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../../files/lib/ankoder/auth_rb.html">
                lib/ankoder/auth.rb
                </a>
        <br />
            </td>
        </tr>

        <tr class="top-aligned-row">
            <td><strong>Parent:</strong></td>
            <td>
                Object
            </td>
        </tr>
        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <p>
Authenticate to the ankoder service
</p>
<pre>
 user = Auth.create(&quot;login&quot;, &quot;password&quot;)
 user.account
</pre>
<p>
If you want to <a href="Auth.html#M000033">recover</a> a session:
</p>
<pre>
 user = Auth.recover(session_id)
 user.account
</pre>
<p>
The initialize and <a href="Auth.html#M000032">create</a> methods can take
blocks.
</p>
<pre>
 Auth.create(&quot;login&quot;, &quot;password&quot;) do |user|
   video = user.videos.find(:first)
   profile = user.profiles.find(:first, :conditions =&gt; {:name =&gt; &quot;iPod 4:3&quot;})
   user.jobs.create :original_file_id =&gt; video.id, :profile_id =&gt; profile.id
 end
</pre>
<p>
All the resources (pluralized) are available within the <a
href="Auth.html">Auth</a> class:
</p>
<pre>
 jobs, videos, profiles, downloads, account
</pre>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000035">account</a>&nbsp;&nbsp;
      <a href="#M000032">create</a>&nbsp;&nbsp;
      <a href="#M000034">destroy</a>&nbsp;&nbsp;
      <a href="#M000031">new</a>&nbsp;&nbsp;
      <a href="#M000033">recover</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">





    <div id="attribute-list">
      <h3 class="section-bar">Attributes</h3>

      <div class="name-list">
        <table>
        <tr class="top-aligned-row context-row">
          <td class="context-item-name">session</td>
          <td class="context-item-value">&nbsp;[R]&nbsp;</td>
          <td class="context-item-desc"></td>
        </tr>
        </table>
      </div>
    </div>
      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000032" class="method-detail">
        <a name="M000032"></a>

        <div class="method-heading">
          <a href="#M000032" class="method-signature">
          <span class="method-name">create</span><span class="method-args">(login, password, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Same as initialize
</p>
<pre>
  Auth::create 'login', 'password'
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000032-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000032-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ankoder/auth.rb, line 48</span>
48:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">create</span>(<span class="ruby-identifier">login</span>, <span class="ruby-identifier">password</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
49:       <span class="ruby-identifier">new</span>(<span class="ruby-identifier">:login</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">login</span>, <span class="ruby-identifier">:password</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">password</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
50:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000031" class="method-detail">
        <a name="M000031"></a>

        <div class="method-heading">
          <a href="#M000031" class="method-signature">
          <span class="method-name">new</span><span class="method-args">(options={}) {|self if block_given?| ...}</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Authenticate to the _ankoderapi_session service
</p>
<p>
options can be:
</p>
<ul>
<li><tt>:login</tt> _ankoderapi_session username

</li>
<li><tt>:password</tt> _ankoderapi_session password

</li>
<li><tt>:session</tt> A previous session, using this option, you will not be
reconnected, you will just <a href="Auth.html#M000033">recover</a> your
session

</li>
</ul>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000031-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000031-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ankoder/auth.rb, line 35</span>
35:                 <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">options</span>={}, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
36:       <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:session</span>]
37:         <span class="ruby-ivar">@session</span> = <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:session</span>]
38:       <span class="ruby-keyword kw">else</span>
39:         <span class="ruby-ivar">@session</span> = <span class="ruby-constant">Browser</span><span class="ruby-operator">::</span><span class="ruby-identifier">login</span>(<span class="ruby-identifier">options</span>[<span class="ruby-identifier">:login</span>], <span class="ruby-identifier">options</span>[<span class="ruby-identifier">:password</span>])
40:         <span class="ruby-ivar">@@sessions</span>.<span class="ruby-identifier">merge!</span>(<span class="ruby-ivar">@session</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">true</span>)
41:       <span class="ruby-keyword kw">end</span>
42:       <span class="ruby-keyword kw">yield</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">block_given?</span>
43:                 <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000033" class="method-detail">
        <a name="M000033"></a>

        <div class="method-heading">
          <a href="#M000033" class="method-signature">
          <span class="method-name">recover</span><span class="method-args">(session, &amp;block)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Recover a session
</p>
<pre>
 Auth.recover(session_id)
</pre>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000033-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000033-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ankoder/auth.rb, line 55</span>
55:     <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">recover</span>(<span class="ruby-identifier">session</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
56:       <span class="ruby-comment cmt">#raise SessionNotFound if @@sessions[session].nil?</span>
57:       <span class="ruby-identifier">new</span>(<span class="ruby-identifier">:session</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">session</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
58:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <h3 class="section-bar">Public Instance methods</h3>

      <div id="method-M000035" class="method-detail">
        <a name="M000035"></a>

        <div class="method-heading">
          <a href="#M000035" class="method-signature">
          <span class="method-name">account</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Show <a href="Auth.html#M000035">account</a> info
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000035-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000035-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ankoder/auth.rb, line 78</span>
78:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">account</span>
79:       <span class="ruby-constant">Account</span>.<span class="ruby-identifier">session</span> = <span class="ruby-ivar">@session</span>
80:       <span class="ruby-constant">Account</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">:first</span>)
81:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000034" class="method-detail">
        <a name="M000034"></a>

        <div class="method-heading">
          <a href="#M000034" class="method-signature">
          <span class="method-name">destroy</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Delete the current session
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000034-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000034-source">
<pre>
    <span class="ruby-comment cmt"># File lib/ankoder/auth.rb, line 72</span>
72:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">destroy</span>
73:       <span class="ruby-ivar">@@sessions</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-ivar">@session</span>)
74:       <span class="ruby-ivar">@session</span> = <span class="ruby-keyword kw">nil</span>
75:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>